package com.neutech.view;

import com.neutech.dao.impl.adminAchieve;
import com.neutech.dao.impl.businessAchieve;
import com.neutech.entity.admin;
import com.neutech.entity.business;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class adminLogon {
    static Scanner input = new Scanner(System.in);
    static adminAchieve ad = new adminAchieve();
    static businessAchieve ba = new businessAchieve();

    public static int adminOn(){
        System.out.print("请输入账号：");
        int businessId = input.nextInt();
        System.out.print("\n请输入密码：");
        String password = input.next();
        int x = ad.getAdminByIdByPass(businessId,password);
        return x;
    }

    public static int register(){
        System.out.print("请输入账号：");
        int adminId = input.nextInt();

        System.out.println("请输入姓名：");
        String adminName = input.next();

        System.out.print("\n请输入密码：");
        String password = input.next();

        admin admin = new admin(adminId,adminName,password);
        int X = ad.addAdmin(admin);
        return X;
    }


    public static void adminInquiryBusiness(){
       ba.listBusiness();
    }

    public static void adminNameManageBusiness(){
        System.out.println("请输入商家名称");
        String name = input.next();
        ba.getBusinessByName(name);
    }

    public static void adminAddBusiness(){
        System.out.print("请输入商家Id");
        int businessId = input.nextInt();
        System.out.println("请输入商家密码");
        String password = input.next();
        System.out.println("请输入商家名称");
        String businessName = input.next();
        System.out.println("请输入商家地址");
        String businessAddress = input.next();
        System.out.println("请输入商家简介");
        String businessExplain = input.next();
        System.out.println("请输入起送价");
        Double starPrice = input.nextDouble();
        System.out.println("请输入配送费");
        Double deliveryPrice = input.nextDouble();

        business business = new business(businessId,password,businessName,businessAddress,businessExplain,starPrice,deliveryPrice);

        ba.addBusiness(business);
    }

    public static void adminUpdateBusiness(){
        System.out.print("请输入商家Id");
        int businessId = input.nextInt();
        System.out.println("请输入商家密码");
        String password = input.next();
        System.out.println("请输入商家名称");
        String businessName = input.next();
        System.out.println("请输入商家地址");
        String businessAddress = input.next();
        System.out.println("请输入商家简介");
        String businessExplain = input.next();
        System.out.println("请输入起送价");
        Double starPrice = input.nextDouble();
        System.out.println("请输入配送费");
        Double deliveryPrice = input.nextDouble();

        business business = new business(businessId,password,businessName,businessAddress,businessExplain,starPrice,deliveryPrice);

        ba.updateBusiness(business);
    }

    public static void adminDeleteBusiness(){
        System.out.println("请输入商家名称");
        String businessName = input.next();
        ba.deleteBusiness(businessName);
    }
}
